﻿@model Jb.Domain.Company
@using Jb.Web.Utility;
@using Jb.Common.Extensions;

@{
	String pageTitle = Model == null ? "Company Home Page" : String.Format("Home Page of {0}", Model.Name);    
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    String _CompanyKey = Jb.Common.DB.NullHandler.GetString(ViewData[AppConstants.ViewDataKeys.COMPANY_KEY]);
    Jb.Web.ViewModels.UtilityModels.ListConfig _ListConfig = ViewData[AppConstants.ViewDataKeys.GENERIC_KEY] as Jb.Web.ViewModels.UtilityModels.ListConfig;
    String _BlankData = AppConstants.ValueOf.UNKNOWN;
    if(_ListConfig.Pager != null){
        if(_CompanyKey.IsNullOrEmpty()){
            _ListConfig.Pager.UrlFormat = "/Company/Details/{0}";
        }
        else{
            _ListConfig.Pager.UrlFormat = "/" + _CompanyKey + "?PageNo={0}";
        }            
    }
}

<div class="jb-page-heading">
    <h1>@pageTitle</h1>
    <div>
        @if (Model != null)
        {
            <div class="float-left">
                @Html.BuildCompanyAddress(
                    (Model.Address.StreetAddress == _BlankData) ? "NA" : Model.Address.StreetAddress,
                    (Model.Address.City == null || Model.Address.City.Name == _BlankData) ? "" : Model.Address.City.Name,
                    (Model.Address.City == null || Model.Address.City.State.Name == _BlankData) ? "" : Model.Address.City.State.Name,
                    (Model.Address.Phone == _BlankData) ? "N/A" : Model.Address.Phone,
                    (Model.Address.Fax == _BlankData) ? "" : Model.Address.Fax,
                    (Model.Address.Email == _BlankData) ? "" : Model.Address.Email,
                    (Model.Address.WebSite == _BlankData) ? "" : Model.Address.WebSite)                
            </div>
            <div class="float-right">
                <img src="@(ImageManager.GetCompanyLogoUrl(Model.LogoFile, Model.ID))" alt="@(Model.Name) Logo" title="@(Model.Name) Logo" />
            </div>
            <div class="clearfix"></div>
        }
    </div>
</div>
    
@Html.ValidationSummary(false)

@if (Model == null) {
    <div class="jb-page-content">
        @Html.WarningMessageBox("Sorry! Requested Company was not found.")
    </div>
}
else if(!Model.IsActive) {
    <div class="jb-page-content">
        @Html.WarningMessageBox(String.Format("Sorry! Requested Company is no longer active in {0}.", ConfigReader.SiteName))
    </div>
}
else {
    <div class="jb-page-content auto">
        <div class="jb-group-title">Recently Published Jobs</div>
    </div>
    @Html.Partial("_JobList", _ListConfig.DataSource)
    if (_ListConfig.Pager != null) {
        String autoClass = _ListConfig.Pager.TotalRecord > 0 ? "auto" : String.Empty;
        <div class="jb-page-content @(autoClass)">
        @Html.Partial("_Pager", _ListConfig.Pager)
        </div>
    }
    @Html.Partial("_SendToFriendModal")
}

@section RightSideBar{
<div style="min-height:200px;"></div>
}

@section JavaScriptPlaceHolder
{
@Html.JavaScript("jquery.validate.min.js", Url)
@Html.JavaScript("jquery.validate.unobtrusive.min.js", Url)
@Html.JavaScript("Common.js", Url)
@Html.Partial("_SendToFriendJS")
}

